﻿/*
 * 由SharpDevelop创建。
 * 用户： Administrator
 * 日期: 2017/6/27
 * 时间: 0:04
 * 
 * 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
 */
using System;

namespace TIDTool
{
	/// <summary>
	/// TidPosition类<br/>
	/// 存储每个音频文件的信息
	/// </summary>
	public class TidPosition
	{
		public int beginOffset;
		public int fileLength;
		public int fileNumber;
		
		public TidPosition(int number, int offset, int len)
		{
			fileNumber = number;
			beginOffset = offset;
			fileLength = len;
		}
		
		#region Equals and GetHashCode implementation
		public override int GetHashCode()
		{
			int hashCode = 0;
				unchecked {
					hashCode += 1000000007 * beginOffset.GetHashCode();
					hashCode += 1000000009 * fileLength.GetHashCode();
				}
					return hashCode;
		}

		public override bool Equals(object obj)
		{
			TidPosition other = obj as TidPosition;
			if (other == null)
				return false;
			return this.beginOffset == other.beginOffset && this.fileLength == other.fileLength;
		}

		public static bool operator ==(TidPosition lhs, TidPosition rhs) {
			if (ReferenceEquals(lhs, rhs))
				return true;
			if (ReferenceEquals(lhs, null) || ReferenceEquals(rhs, null))
				return false;
			return lhs.Equals(rhs);
		}

		public static bool operator !=(TidPosition lhs, TidPosition rhs) {
			return !(lhs == rhs);
		}

		#endregion
	}
}
